//
//  two-colorHanoi.cpp
//  Algorithm
//
//  Created by 刘锦程 on 2023/9/13.
//
#include<queue>
#include <stdio.h>
#include<iostream>

using namespace std;
int n;
int A[20],B[20],C[20];
int aa[100];
char ans[100000],k;
int num1,num2;
void twoHanoi(char a,char c,char b,int n){
    if(n==1){
        cout<<a<<"->"<<b<<endl;
        return;
    }else{
        twoHanoi(a,b,c,n-1);
        twoHanoi(a,c,b,1);
        twoHanoi(c,a,b,n-1);
    }
}

void print(){
    int i=1;
    while(ans[i]!=0){
        num1++;
        cout<<ans[i]<<"->"<<ans[i+1]<<endl;
        i+=2;
    }
}
void dfs(int a,int b,int c,int k){
    if(b-1==n){
        print();
        exit(0);
    }
        for(int i=1;i<=3;i++){
            if(i==1){
                if(ans[k-1]=='A')continue;
                ans[k++]='A';
                if(n%2==0){
                    if((A[a-1]<C[c-1]&&A[a-1]%2!=C[c-1]%2)||C[c-1]==2147483647){
                        C[c]=A[a-1];
                        ans[k]='C';
                        dfs(a-1,b,c+1,k+1);
                        
                    }
                    else if((A[a-1]<B[b-1]&&A[a-1]%2!=B[b-1]%2)||B[b-1]==2147483647){
                        B[b]=A[a-1];
                        ans[k]='B';
                        dfs(a-1,b+1,c,k+1);
                        
                    }
                }else{
                    if((A[a-1]<B[b-1]&&A[a-1]%2!=B[b-1]%2)||B[b-1]==2147483647){
                        B[b]=A[a-1];
                        ans[k]='B';
                        dfs(a-1,b+1,c,k+1);
                        
                    }
                   else if((A[a-1]<C[c-1]&&A[a-1]%2!=C[c-1]%2)||C[c-1]==2147483647){
                        C[c]=A[a-1];
                        ans[k]='C';
                        dfs(a-1,b,c+1,k+1);
                        
                    }

                }
                ans[--k]=0;
            }else if(i==2){
                if(ans[k-1]=='B') continue;
                ans[k++]='B';
                if((B[b-1]<C[c-1]&&C[c-1]%2!=B[b-1]%2)||C[c-1]==2147483647){
                    C[c]=B[b-1];
                    ans[k]='C';
                    dfs(a,b-1,c+1,k+1);
                    
                }else if((B[b-1]<A[a-1]&&A[a-1]%2!=B[b-1]%2)||A[a-1]==2147483647){
                    A[a]=B[b-1];
                    ans[k]='A';
                    dfs(a+1,b-1,c,k+1);
                    
                }
                ans[--k]=0;
            }else{
                if(ans[k-1]=='C') continue;
                ans[k++]='C';
                if((C[c-1]<B[b-1]&&C[c-1]%2!=B[b-1]%2)||B[b-1]==2147483647){
                    B[b]=C[c-1];
                    ans[k]='B';
                    dfs(a,b+1,c-1,k+1);
                    
                }else if((C[c-1]<A[a-1]&&A[a-1]%2!=C[c-1]%2)||A[a-1]==2147483647){
                    A[a]=C[c-1];
                    ans[k]='A';
                    dfs(a+1,b,c-1,k+1);
                    
                }
                ans[--k]=0;
            }
        }
}
int ans11(){
    cin>>n;
    for(int i=1;i<=n;i++){
        A[i]=n-i+1;
    }
    
    twoHanoi('a','c','b',n);
    cout<<"--------------------"<<endl;
    A[0]=2147483647;
    B[0]=2147483647;
    C[0]=2147483647;
    dfs(n+1,1,1,1);
    
    return 0;
}
